package net.siufung.market.base.dept.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;
import net.siufung.core.model.EnumsVo;
import net.siufung.core.model.IEnum;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 陈建峰
 * @since 2022/8/2 6:33 下午
 */
@ToString
@AllArgsConstructor
public enum DeptTypes implements IEnum<String> {

    /**
     * 公司
     */
    COMPANY("0", "公司"),
    /**
     * 部门
     */
    DEPARTMENT("1", "部门"),
    /**
     * 小组
     */
    GROUP("2", "小组");

    @Getter
    private final String value;
    @Getter
    private final String text;


    public static DeptTypes get(String value) {
        return IEnum.get(DeptTypes.class,
                enums -> enums.getValue().equals(value));
    }

    public static String getDesc(String value) {
        return IEnum.getDesc(DeptTypes.class,
                enums -> enums.getValue().equals(value));
    }

    public static List<EnumsVo> getList(){
        return IEnum.findList(DeptTypes.class).stream()
                .map(element -> new EnumsVo(element.getValue(), element.getDesc(), element.getText()))
                .collect(Collectors.toList());
    }
}
